package cn.zust.ly.entity;

import org.hibernate.annotations.FilterJoinTables;

import javax.persistence.*;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Created by liy on 2016/10/12.
 */
@Entity
@Table(name = "tpicture")
public class Tpicture {

    private int id;
    private String name;
    private String fname;
    private Tuser user;
    private String intro;
    private String tags;
    private Date uploadTime;
    private int clickNum;

    public Tpicture () {}

    public Tpicture(String name, String fname, Tuser user, String intro, String tags, Date uploadTime, int clickNum) {
        this.name = name;
        this.fname = fname;
        this.user = user;
        this.intro = intro;
        this.tags = tags;
        this.uploadTime = uploadTime;
        this.clickNum = clickNum;
    }

    public Tpicture(String fname, Tuser user, String tags, Date uploadTime, int clickNum) {
        this.fname = fname;
        this.user = user;
        this.tags = tags;
        this.uploadTime = uploadTime;
        this.clickNum = clickNum;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "fname")
    public String getFname() {
        return fname;
    }

    public void setFname(String fname) {
        this.fname = fname;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    public Tuser getUser() {
        return user;
    }

    public void setUser(Tuser user) {
        this.user = user;
    }

    @Column(name = "intro")
    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    @Column(name = "tags")
    public String getTags() {
        return tags;
    }

    public void setTags(String tags) {
        this.tags = tags;
    }

    @Column(name = "upload_time")
    public Date getUploadTime() {
        return uploadTime;
    }

    public void setUploadTime(Date uploadTime) {
        this.uploadTime = uploadTime;
    }

    @Column(name = "click_num")
    public int getClickNum() {
        return clickNum;
    }

    public void setClickNum(int clickNum) {
        this.clickNum = clickNum;
    }


    @Override
    public String toString() {
        return "Tpicture{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", fname='" + fname + '\'' +
                ", user=" + user.getName() +
                ", intro='" + intro + '\'' +
                ", tags='" + tags + '\'' +
                ", uploadTime=" + uploadTime +
                ", clickNum=" + clickNum +
                '}';
    }
}
